<template>
<el-form :model="form" ref="ruleForm2" label-position="left" label-width="0px" class="demo-ruleForm login-container">
  <h3 class="title">家电商城系统后台登录</h3>
  <el-form-item prop="account">
    <el-input type="text" v-model="form.username" auto-complete="off" placeholder="账号/邮箱/手机"></el-input>
  </el-form-item>
  <el-form-item prop="checkPass">
    <el-input type="password" v-model="form.password" auto-complete="off" placeholder="密码"></el-input>
  </el-form-item>
  <el-checkbox v-model="form.remember" checked class="remember">记住密码</el-checkbox>
  <el-form-item style="width:100%;">
    <el-button type="primary" style="width:100%;" @click.native.prevent="handleSubmit" :loading="logining">登录</el-button>
  </el-form-item>
</el-form>
</template>

<script>
import * as types from '../../../store/mutations.js'
import * as auth from '../../../api/auth.js'

export default {
  data() {
    return {
      logining: false,
      form: {
        username: '',
        password: '',
        remember: false
      },
      checked: false
    };
  },
  methods: {
    handleReset() {
      // this.$refs.ruleForm2.resetFields();
    },
    handleSubmit(ev) {
      auth.login(this.form.username, this.form.password, this.form.remember).then(data => {
        this.$store.dispatch('login', data);
        let redirect = decodeURIComponent(this.$route.query.redirect || '/dashboard');
        this.$router.push({
          path: redirect
        });
      });
    }
  }
}
</script>

<style lang="less" scoped>
.login-container {
    /*box-shadow: 0 0px 8px 0 rgba(0, 0, 0, 0.06), 0 1px 0px 0 rgba(0, 0, 0, 0.02);*/
    -webkit-border-radius: 5px;
    border-radius: 5px;
    -moz-border-radius: 5px;
    background-clip: padding-box;
    margin: 180px auto;
    width: 350px;
    padding: 35px 35px 15px;
    background: #fff;
    border: 1px solid #eaeaea;
    box-shadow: 0 0 25px #cac6c6;
    .title {
        margin: 0 auto 40px;
        text-align: center;
        color: #505458;
    }
    .remember {
        margin: 0 0 35px;
    }
}
</style>
